package main

import (
	"fmt"
	"strings"
)

func add(a int) func(int) int {
	return func(y int) int {
		a += y
		return a
	}
}
func makeSuffixFunc(suffix string) func(string) string {
	return func(name string) string {
		if !strings.HasSuffix(name, suffix) {
			return name + suffix
		}
		return name
	}
}
func calc(base int) (func(int) int, func(int) int) {
	add := func(i int) int {
		base += i
		return base
	}

	sub := func(i int) int {
		base -= i
		return base
	}
	return add, sub
}
func main() {
	/*	jpgFunc := makeSuffixFunc(".jpg")
		txtFunc := makeSuffixFunc(".txt")
		fmt.Println(jpgFunc("test")) //test.jpg
		fmt.Println(txtFunc("test")) //test.txt*/
	a1, a2 := calc(3)
	fmt.Println(a1(1), a2(2))
}
